﻿package b3.widget.mail
{
	import b3.config.*;
	import b3.model.*;
	import b3.net.*;
	import b3.scene.*;
	import b3.scene.build.*;
	import b3.scene.home.*;
	import b3.scene.home.grid.*;
	import b3.util.*;
	import b3.widget.*;
	import b3.widget.basic.*;
	
	import com.greensock.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.text.*;
	import flash.ui.Mouse;

	public class MailTypeItem extends Sprite
	{
		public var objectIndex:int;

		public function MailTypeItem(objectIndex:int)
		{
			super();
			this.objectIndex = objectIndex;
			var objectConfig:ObjConfig = Config.objConfigs[objectIndex];
			//背景框
			var tabItemBackground:Sprite = new Sprite();
			tabItemBackground.graphics.beginFill(0xFFFFFF, 0);
			tabItemBackground.graphics.drawRect(0, 0, 92, 112);
			tabItemBackground.graphics.endFill();
			addChild(tabItemBackground);
			//图片
			var ObjectImage:Class = ResourceHelper.getInstance().getClassByName(objectConfig.iconImage[0]);   
			var img:Sprite = new ObjectImage();
			img.width = 60;
			img.scaleY = img.scaleX;
			img.x = (this.width - img.width) / 2;
			img.y = 25;
			addChild(img);
			//标题名字
			var titleText:TextField = new TextField();
			titleText.selectable = false;
        	titleText.autoSize = TextFieldAutoSize.LEFT;
        	if (objectConfig.name.length < 6)
        	{
        		titleText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x0088FF, true);
        	}
        	else
        	{
        		titleText.defaultTextFormat = new TextFormat("微软雅黑", 13, 0x0088FF, true);
        	}
			titleText.filters = [new GlowFilter(0xFFFFFF, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			titleText.text = objectConfig.name;
			titleText.x = (tabItemBackground.width - titleText.width) / 2;
			titleText.y = 85;
			addChild(titleText);
			this.mouseChildren = false;
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}

		private function onMouseOver(event:MouseEvent):void
		{
			Mouse.cursor = "button";
			this.filters = [new ColorMatrixFilter(BFont.brightFilter)];
		}    
		
		private function onMouseOut(event:MouseEvent):void
		{
			Mouse.cursor = "auto";
			this.filters = null;
		}
	}
}